package com.enniswu.weitter.user.userlist;

import android.support.annotation.Nullable;

import com.enniswu.weitter.base.BasePresenter;
import com.enniswu.weitter.data.remote.UserLoader;
import com.enniswu.weitter.entity.User;

import java.util.List;

public class UserListPresenter extends BasePresenter<UserListContract.View> implements UserListContract.Presenter {

    private UserLoader loader;

    public UserListPresenter(UserListContract.View view) {
        super(view);
        loader = new UserLoader();
    }

    @Override
    public void getUser(List<Integer> ids) {
        for (int i : ids) {
            loader.getInfo(i, new AbstractCallback<User>() {
                @Override
                public void onSuccess(@Nullable User user) {
                    if (user != null && view != null)
                        view.addUser(user);
                }
            });
        }
    }
}
